using MediatR;
using B.S.RbacData.ErrorCode;
using System.ComponentModel.DataAnnotations;

namespace SupplierCustomerManagement.Write.API.Applications.Commands.attachments
{
    /// <summary>
    /// 添加附件命令
    /// </summary>
    public class AddAttachmentCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// 附件文件
        /// </summary>
        [Required(ErrorMessage = "附件文件不能为空")]
        public IFormFile AttachmentFile { get; set; }

        /// <summary>
        /// 关联实体ID（客户ID、供应商ID、商品采购价格ID等）
        /// </summary>
        [Required(ErrorMessage = "关联实体ID不能为空")]
        public int RelatedEntityId { get; set; }

        /// <summary>
        /// 关联实体类型（Customer/Supplier/ProductPurchasePrice等）
        /// </summary>
        [Required(ErrorMessage = "关联实体类型不能为空")]
        [StringLength(50, ErrorMessage = "关联实体类型长度不能超过50个字符")]
        public string RelatedEntityType { get; set; } = string.Empty;

        /// <summary>
        /// 存储桶名称
        /// </summary>
        public string BucketName { get; set; } = "attachments";

        /// <summary>
        /// 文件前缀路径（可选）
        /// </summary>
        public string Prefix { get; set; } = "files";

        /// <summary>
        /// 是否生成唯一文件名
        /// </summary>
        public bool GenerateUniqueName { get; set; } = true;

        /// <summary>
        /// 上传人ID
        /// </summary>
        public int? UploaderId { get; set; }

        /// <summary>
        /// 上传人姓名
        /// </summary>
        [StringLength(100, ErrorMessage = "上传人姓名长度不能超过100个字符")]
        public string? UploaderName { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")]
        public string? Remarks { get; set; }
    }
} 